package com.example.demo.mapper;

import com.example.demo.pojo.entity.Diet;
import com.example.demo.pojo.entity.UserDiet;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DietMapper {
    @Select("Select * from user_diet where user_id=#{userId}")
    List<UserDiet> getDietByUserId(Long userId);

    @Select("select * from diet where type=#{type}")
    List<Diet> getDietBytype(String type);

    @Insert("insert into user_diet (user_id, time, food, create_time) VALUES " +
            "(#{userId},#{time},#{food},#{createTime})")
    void insert(UserDiet userDiet);

    @Update("update user_diet set is_finish=#{isDinish} where id=#{id}")
    void update(UserDiet userDiet);
}
